"use strict";
cc._RF.push(module, '6376dIDcD1B/6S6cZZ/sy9D', 'GameOverViewUI');
// scripts/GameOverViewUI.js

"use strict";

var e = require;
var t = module;
var o = exports;

var _ii,
    nn = void 0 && (void 0).__extends || (_ii = function ii(t, e) {
  return (_ii = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _ii(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    rr = void 0 && (void 0).__awaiter || function (t, e, o, i) {
  return new (o || (o = Promise))(function (n, a) {
    function r(t) {
      try {
        l(i.next(t));
      } catch (e) {
        a(e);
      }
    }

    function s(t) {
      try {
        l(i["throw"](t));
      } catch (e) {
        a(e);
      }
    }

    function l(t) {
      var e;
      t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
        t(e);
      })).then(r, s);
    }

    l((i = i.apply(t, e || [])).next());
  });
};

var oo = void 0 && (void 0).__decorate || function (e, t, a, n) {
  var i,
      o = arguments.length,
      s = o < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, a) : n;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);else for (var r = e.length - 1; r >= 0; r--) {
    (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
  }
  return o > 3 && s && Object.defineProperty(t, a, s), s;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var a = e("BaseModuleUI"),
    n = e("GlobalParams"),
    i = e("AssetsManager"),
    r = e("AudioManager"),
    s = e("Game"),
    l = e("ObtainHeroTipView"),
    _ = e("sdkConfig"),
    c = e("AD"),
    d = e("Toast"),
    h = cc._decorator,
    u = h.ccclass,
    p = h.property,
    m = function (e) {
  function t() {
    var t = null !== e && e.apply(this, arguments) || this;
    return t.hero_ske = [], t.win_or_lose = null, t.level_node = null, t.level_next_node = null, t.exp_num = null, t.power_num = null, t.coin_num = null, t.zs_num = null, t.share_view_node = null, t.btn_view_node = null, t.add_coin = 0, t.add_zs = 0, t.is_key_award = !1, t;
  }

  return nn(t, e), t.prototype.initView = function () {
    var t = this;
    if (e.prototype.initView.call(this), c["default"].getInstance().getGameTestVersion() && c["default"].getInstance().showInter(), this.share_view_node.active = _["default"].platform == _.EPlatform.TikTok, _["default"].platform != _.EPlatform.TikTok || c["default"].getInstance().getGameTestVersion()) this.btn_view_node.active = !0;else {
      var o = n.GlobalParams.ShareVidoeInfo.value;
      this.btn_view_node.active = o == new Date().toLocaleDateString(), this.btn_view_node.active || this.scheduleOnce(function () {
        t.btn_view_node.active = !0;
      }, 2);
    }
    n.GlobalParams.PlayGuideMode = !1, c["default"].getInstance().showInter(), this.showViewInfo();
  }, t.prototype.addEvent = function () {
    cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
  }, t.prototype.showViewInfo = function () {
    var e = this,
        t = n.GlobalParams.FightDataInfo.value;
    t.fight_num += 1, n.GlobalParams.GamePlayerWin && (t.win_num += 1), n.GlobalParams.FightDataInfo.value = t, this.win_or_lose.children[0].active = n.GlobalParams.GamePlayerWin, this.win_or_lose.children[1].active = !n.GlobalParams.GamePlayerWin;
    var o = n.GlobalParams.PlayerInfo.value,
        a = n.GlobalParams.MatchGamePlayer[n.GlobalParams.MatchMyIndex].kill_info,
        r = 0;
    if (2 != n.GlobalParams.MultiModeIndex) this.hero_ske[1].node.active = !1, this.hero_ske[2].node.active = !1, this.uiManager.getRoleSkele(n.GlobalParams.MatchGamePlayer[n.GlobalParams.MatchMyIndex].role_id, function (t) {
      e.hero_ske[0].skeletonData = t, e.hero_ske[0].setAnimation(0, "battle_idle", !0);
    }), this.power_num.node.parent.active = !1, r = n.GlobalParams.GamePlayerWin ? 500 : 200;else {
      for (var _ = function _(t) {
        c.hero_ske[t].node.active = !0, c.uiManager.getRoleSkele(n.GlobalParams.MatchGamePlayer[t].role_id, function (o) {
          e.hero_ske[t].skeletonData = o, e.hero_ske[t].setAnimation(0, "battle_idle", !0);
        });
      }, c = this, d = 0; d < 3; d++) {
        _(d);
      }

      this.power_num.node.parent.active = !0, r = 200;
      var h = n.GlobalParams.DarePlayerInfo[0].power,
          u = n.GlobalParams.GamePlayerWin ? n.GlobalParams.DarePlayerInfo[1].power : h,
          p = h > u ? h : u;
      this.power_num.string = p + "";
      var m = n.GlobalParams.DungeonModeHero.value;
      m.power = p, m.update_dare = !0, n.GlobalParams.DungeonModeHero.value = m;
    }
    var f = o.exp + r,
        v = Math.floor(o.level / 10);
    v = v > 6 ? 6 : v;
    var g = s["default"].season_exp[v];

    if (this.level_node.children[0].getComponent(cc.Sprite).spriteFrame = i["default"].getInstance().getPlayerLevelExp(v), this.level_node.children[1].getComponent(cc.Label).string = "Lv. " + o.level, f >= g) {
      o.level += 1, f -= g, this.level_next_node.active = !0;
      var y = Math.floor(o.level / 10);
      y = y > 6 ? 6 : y, this.level_next_node.children[0].getComponent(cc.Sprite).spriteFrame = i["default"].getInstance().getPlayerLevelExp(y), this.level_next_node.children[1].getComponent(cc.Label).string = "Lv. " + o.level;
    } else this.level_next_node.active = !1;

    o.exp = f, n.GlobalParams.PlayerInfo.value = o, n.GlobalParams.GamePlayerWin && (this.uiManager.playerTaskOverInfo(3, 1), this.uiManager.playerTaskOverInfo(4, 1), this.uiManager.playerTaskOverInfo(8, 1)), this.add_coin = n.GlobalParams.GamePlayerWin ? 100 : 20, this.add_coin += 3 * a[0] - 2 * a[1] + 0.5 * a[2], this.add_coin = Math.ceil(this.add_coin), this.add_zs = n.GlobalParams.GamePlayerWin ? 10 : 2, this.coin_num.string = "+" + this.add_coin, this.zs_num.string = "+" + this.add_zs, o.first_fight && (this.uiManager.addTykNum(1), o.first_fight = !1, n.GlobalParams.PlayerInfo.value = o, this.uiManager.showPopup("ObtainHeroTipView", function (e) {
      e.getComponent(l["default"]).showHeroTipInfo(!0);
    })), n.GlobalParams.ShowTextIcon = !0, this.is_key_award = !0;
  }, t.prototype.OnClick = function (t) {
    var o = this;
    e.prototype.OnClick.call(this, t);
    var a = t.node.name;

    switch (a) {
      case "get_btn":
      case "three_btn":
        this.getAwardInfo(a);
        break;

      case "share_btn":
        var i = n.GlobalParams.ShareVidoeInfo.value;
        c["default"].getInstance().ShareVideo(function () {
          i != new Date().toLocaleDateString() && (o.uiManager.addTykNum(1), i = new Date().toLocaleDateString(), n.GlobalParams.ShareVidoeInfo.value = i, d["default"].showNewToast("分享成功，获得英雄体验卡*1"), o.share_view_node.active = !1, o.btn_view_node.active = !0);
        }, function () {
          d["default"].showNewToast("分享失败");
        });
    }
  }, t.prototype.getAwardInfo = function (e) {
    var t = this,
        o = function o() {
      var o = t.add_coin * ("get_btn" == e ? 1 : 3),
          a = t.add_zs * ("get_btn" == e ? 1 : 3);
      t.uiManager.addCoinNum(o), t.uiManager.addZsNum(a), t.uiManager.showTopView(!1), 2 != n.GlobalParams.MultiModeIndex ? cc.find("Canvas").addChild(cc.instantiate(i["default"].getInstance().getFightPrefab("GameOverMenuViewUI"))) : cc.director.loadScene("Main"), t.closePopup();
    };

    "three_btn" == e ? c["default"].getInstance().showVideo(function (e) {
      r["default"].playGameBGM(), e == c.ResultEnum.Success && o();
    }) : o();
  }, t.prototype.onKeyUp = function (e) {
    if (this.is_key_award) switch (this.is_key_award = !1, e.keyCode) {
      case cc.macro.KEY.g:
        this.getAwardInfo("get_btn");
        break;

      case cc.macro.KEY.enter:
        this.getAwardInfo("three_btn");
    }
  }, oo([p(sp.Skeleton)], t.prototype, "hero_ske", void 0), oo([p(cc.Node)], t.prototype, "win_or_lose", void 0), oo([p(cc.Node)], t.prototype, "level_node", void 0), oo([p(cc.Node)], t.prototype, "level_next_node", void 0), oo([p(cc.Label)], t.prototype, "exp_num", void 0), oo([p(cc.Label)], t.prototype, "power_num", void 0), oo([p(cc.Label)], t.prototype, "coin_num", void 0), oo([p(cc.Label)], t.prototype, "zs_num", void 0), oo([p(cc.Node)], t.prototype, "share_view_node", void 0), oo([p(cc.Node)], t.prototype, "btn_view_node", void 0), oo([u], t);
}(a["default"]);

o["default"] = m;

cc._RF.pop();